/*
 * This file is Copyright 2002-2006 Loyola University Chicago,
 * Department of Computer Science and the Emerging Technologies Laboratory.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License via
 *    http://www.apache.org/licenses/LICENSE-2.0.
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.citep.business;

import java.util.Date;
import java.math.BigDecimal;
import java.util.Set;

/**
 * The Account interface represents an Account.  It provides all methods for 
 * setting and getting information about Accounts.  
 * 
 * <br><br>Any changes made to an Account object through setters or 'add'
 * methods will not be persisted until the updateAccount() method in the 
 * AccountManager is called on the object.
 *
 * @author     yogesh, mbone, bgonzalez
 * @version    1.1
 * @since      May 15, 2003
 * @see AccountManager
 */

public abstract class Account {
	

	public abstract boolean hasParent();
	
	public abstract Account getParent();
	public abstract void setParent(Account parent);
	
	public abstract boolean hasChildren();
	
	public abstract Set<Account> getChildren();
	public abstract void setChildren(Set<Account> children);
	
	public abstract int getId();
	public abstract void setId(int id);
	
	public abstract String getDescription();
	public abstract void setDescription(String description);
	
	public abstract String getName();
	public abstract void setName(String name);

	public abstract Date getStartPeriod();
	public abstract void setStartPeriod(Date startPeriod);
	
	public abstract Date getEndPeriod();
	public abstract void setEndPeriod(Date endPeriod);
		
	public abstract BigDecimal getCurrentBalance();
	public abstract void setCurrentBalance(BigDecimal currentBalance);
	
	public abstract boolean isEnabled();
	public abstract void setEnabled(boolean enabled);
	
	public abstract void setType(AccountTypes type);
	public abstract AccountTypes getType();
	
	public abstract void setAccountCategory(AccountCategory category);
	public abstract AccountCategory getAccountCategory();
	
	public abstract Date getLastModified();
	public abstract void setLastModified(Date date);
	

	@Override
	public boolean equals(Object o) {
		System.out.println("Account.equals: " + this + " vs. " + o);
		
		if(o == null)
			return false;
		
		try {
			Account other;
			other = (Account)o;
			
			if(other.getId() == getId())
				return true;
			
			if(other.getName() == getName()) {
				Account otherParent = other.getParent();
				
				if(otherParent == null)
					return getParent() == null;
				
				return otherParent.equals(getParent());
			} else {
				return false;
			}
			
		} catch(Exception e) {
			return false;
		}
	}

	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		return super.hashCode();
	}
	
}
